using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
using System.Runtime.Serialization;
using CoreData;
namespace OpenIDHostController.DataContract
{
    [DataContract]
    public class user_groupContract
    {
        [DataMember]
        public long id { get; set; }
        [DataMember]
            public long userid{get;set;}
        [DataMember]
            public long groupid{get;set;}

        public user_groupContract()
        {       
        }

        public static user_groupContract ToContract(user_group data)
        {
            try
            {
                var model = ConvertObject.ConvertToObject(new user_groupContract());
                Helper.ConvertObject.ConvertEntityToModel(data, ref model);
                return (user_groupContract)model;
            }
            catch
            {
                return null;
            }
        }
        public static user_group ToCoreData(user_groupContract data)
        {
            try
            {
                var model = ConvertObject.ConvertToObject(new user_group());
                Helper.ConvertObject.ConvertEntityToModel(data, ref model);
                return (user_group)model;
            }
            catch
            {
                return null;
            }
        }

        public static IList<user_group> ToListCoreData(IList<user_groupContract> data)
        {
            var list = new List<user_group>();
            foreach (var item in data)
            {
                var model = ConvertObject.ConvertToObject(new user_group());
                Helper.ConvertObject.ConvertEntityToModel(item, ref model);
                if (model != null)
                {
                    list.Add((user_group)model);
                }
            }
            if (list.Count <= 0)
                return null;
            return list;
        }
        public static IList<user_groupContract> ToListConTract(IList<user_group> data)
        {
            var list = new List<user_groupContract>();
            foreach (var item in data)
            {
                var model = ConvertObject.ConvertToObject(new user_groupContract());
                Helper.ConvertObject.ConvertEntityToModel(item, ref model);
                if (model != null)
                {
                    list.Add((user_groupContract)model);
                }
            }
            if (list.Count <= 0)
                return null;
            return list;
        }
        
    }
}
